home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Light ROM 1
/
LIGHT-ROM 1 (Amiga Library Services)(1994).iso
/
ffdisks
/
d903.lha
/
MICE
/
Brushes
/
ADonBi
< prev
next >
Wrap
Text File
|
1993-08-26
|
17KB
|
1,134 lines
upgadget: * attend l'addresse du gadget en a0
movea.l a0,a3
andi.w #SELECTED,gg_Flags(a0)
movea.l MiceHandle,a1
suba.l a2,a2
moveq #1,d0
CALLINT RefreshGList
movea.l a3,a0
andi.w #~SELECTED,gg_Flags(a0)
movea.l MiceHandle,a1
suba.l a2,a2
moveq #1,d0
CALLINT RefreshGList
rts
ItoA: * convert integer to ascii. attend la valeur en d0
* return :
* a0 : codes ascii
* d6 : rang a/c a0 du 1° ascii non nul (<>$30)
lea ItoA_Result,a0 chaine à ecrire en a0.
lea ItoA_Offs,a1 table des 10^n à oter de d0.
moveq #3,d1 compteur : 4 valeurs
.rang move.w (a1)+,d3
moveq #$D0,d2 d2=-$30
.soust sub.w d3,d0 on soustrait 10^n de d0 jusquà ce
dbmi d2,.soust que le result soit negatif.
neg.b d2 puis représentatn >0 de l' ascii
move.b d2,(a0)+ qu'on stocke.
add.w d3,d0 on a fait une soust de trop.
dbra d1,.rang exit qd on a les 4 chiffres
rts
ascii: * range les valeurs exprimes en ascii a l'addr en a0
* et leur longueur a l'addr en a1
lea ItoA_Result,a2
clr.l d0
1$ cmpi.b #$30,(a2,d0)
bne 2$
addq #1,d0
bra 1$
2$ move.w d0,d5
neg.w d5
addq.w #4,d5
move.w d5,(a1)
subq.w #1,d5
3$ move.b (a2,d0.w),(a0)+
addq.w #1,d0
dbra d5,3$
rts
get_wh_ascii:
move.w PicWidth,d0
bsr ItoA
lea AscPicWidth,a0
lea AscPicWidthLength,a1
bsr ascii
move.w PicHeight,d0
bsr ItoA
lea AscPicHeight,a0
lea AscPicHeightLength,a1
bsr ascii
rts
test_1st_chr: * attend filename en a1
cmpi.b #'A',(a1)
bmi bad_1st_chr
cmpi.b #'z',(a1)
bpl bad_1st_chr
cmpi.b #'[',(a1)
beq bad_1st_chr
cmpi.b #'\',(a1)
beq bad_1st_chr
cmpi.b #']',(a1)
beq bad_1st_chr
cmpi.b #'^',(a1)
beq bad_1st_chr
cmpi.b #'`',(a1)
beq bad_1st_chr
rts
bad_1st_chr:
tst.l mrq_ExtendedSelect
beq 25$
move.w #1,es_Pad(a5)
lea File,a0
bsr copy_string
25$ lea File,a1
lea Error_14,a0
30$ cmpi.b #0,(a1)
beq 35$
move.b (a1)+,(a0)+
bra 30$
35$ move.b #39,(a0)+ #39 = chr '
move.b #' ',(a0)+
move.b #':',(a0)+
lea Error_17,a1
move.w #Error_17_Length-1,d5
40$ move.b (a1)+,(a0)+
dbra d5,40$
move.b #0,(a0)
move.l #Error_10,mtr_Text
move.l #ok,mtr_MiddleText
lea MiceTRStructure,a0
CALLREQ TextRequest
bset #MBADFIRSTCHRB,d7
clr.l mtr_MiddleText
rts
copy_FileName:
lea File,a3 filename
cmpi.b #'a',(a3) commence par une majuscule ?
bmi 7$
cmpi.b #'z',(a3)
bpl 7$
subi.b #$20,(a3)
7$ move.w FileNameLength,d5
subi.w #1,d5
10$ move.b (a3)+,(a4)+
dbra d5,10$
rts
copy_to_PathName:
lea PathName,a0
lea Dir,a1
5$ cmpi.b #0,(a1)
beq 10$
move.b (a1)+,(a0)+
bra 5$
10$ move.b #'/',(a0)+
movea.l a5,a1
adda.l #es_SIZEOF,a1
15$ cmpi.b #0,(a1)
beq 20$
move.b (a1)+,(a0)+
bra 15$
20$ move.b #0,(a0)
rts
copy_to_File:
movea.l a5,a1
adda.l #es_SIZEOF,a1
lea File,a0 copy filename to File for coding
copy_string:
15$ cmpi.b #0,(a1)
beq 20$
move.b (a1)+,(a0)+
bra 15$
20$ move.b #0,(a0)
rts
chr_count: *** calculage du nbre de lettres du fichier
chr_count1:
lea File,a3
clr.l d6
chr addq.w #1,d6
cmpi.b #'0',(a3,d6)
bmi end_chr
cmpi.b #'z',(a3,d6)
bpl end_chr
cmpi.b #':',(a3,d6)
beq end_chr
cmpi.b #';',(a3,d6)
beq end_chr
cmpi.b #'<',(a3,d6)
beq end_chr
cmpi.b #'=',(a3,d6)
beq end_chr
cmpi.b #'>',(a3,d6)
beq end_chr
cmpi.b #'?',(a3,d6)
beq end_chr
cmpi.b #'@',(a3,d6)
beq end_chr
cmpi.b #'[',(a3,d6)
beq end_chr
cmpi.b #'\',(a3,d6)
beq end_chr
cmpi.b #']',(a3,d6)
beq end_chr
cmpi.b #'^',(a3,d6)
beq end_chr
cmpi.b #'`',(a3,d6)
beq end_chr
bra chr
end_chr move.w d6,FileNameLength
rts
test_IFF:
move.l #PathName,d1 filename en d1
moveq #ACCESS_READ,d2 acces lecture
CALLDOS Lock on obtient le lock
move.l d0,Lock
bne 5$
bsr no_open_file
rts
5$ move.l #PathName,d1 ouverture fichier a charger
move.l #MODE_OLDFILE,d2
CALLDOS Open
move.l d0,IFFFileHandle
bne 10$
bsr no_open_file
bra 55$ libere le lock
10$ move.l IFFFileHandle,d1 filehandle en d1
move.l #TestFile,d2 la ou il doit etre ecrit
moveq #12,d3 nb octets a ecrire
CALLDOS Read
lea TestFile,a0
cmpi.l #'FORM',(a0)
beq 40$
bsr no_IFF
bra 50$
40$ cmpi.l #'ILBM',8(a0)
beq 50$
bsr no_ILBM
50$ move.l IFFFileHandle,d1 filehandle en d1
CALLDOS Close cloture
55$ move.l Lock,d1 liberation du lock
CALLDOS UnLock
rts
open_IFF: * ouvrage du fichier iff
move.l #fib_SIZEOF,d0 mem pr FileInfoBlock
move.l #MEMF_PUBLIC|MEMF_CLEAR,d1
CALLEXEC AllocMem
move.l d0,FIB
bne 3$
bsr no_open_file
rts
3$ move.l #PathName,d1 filename en d1
moveq #ACCESS_READ,d2 acces lecture
CALLDOS Lock on obtient le lock
move.l d0,Lock
bne 5$
bsr no_open_file
bra 20$
5$ move.l Lock,d1 lock en d1
move.l FIB,d2 FIB en d2
CALLDOS Examine
movea.l FIB,a0
move.l fib_Size(a0),IFFSize taille IFFFile en IFFSize
move.l IFFSize,d0 mem pour fichier a charger
moveq #MEMF_PUBLIC,d1
CALLEXEC AllocMem
move.l d0,IFFFile adresse en IFFFile
bne 7$
bsr no_open_file
bra 15$
7$ move.l #PathName,d1 ouverture fichier a charger
move.l #MODE_OLDFILE,d2
CALLDOS Open
move.l d0,IFFFileHandle *** filehandle en d5
bne 10$
bsr no_open_file
bra 15$
10$ move.l IFFFileHandle,d1 filehandle en d1
move.l IFFFile,d2 la ou il doit etre ecrit
move.l IFFSize,d3 nb octets a ecrire
CALLDOS Read
move.l IFFFileHandle,d1 filehandle en d1
CALLDOS Close cloture
15$ move.l Lock,d1 liberation du lock
CALLDOS UnLock
20$ movea.l FIB,a1 liberation mem FIB
move.l #fib_SIZEOF,d0
CALLEXEC FreeMem
rts
getCHUNKS: * obtenage des chunks BODY, BMHD, CMAP, DEST
move.l a4,-(sp)
movea.l IFFFile,a5
movea.l a5,a4
adda.l IFFSize,a4 fin IFF en a4.
adda.l #12,a5 apres 'FORM XXXX ILBM'.
0$ cmpi.l #'BODY',(a5) cherchage du BODY
beq 10$
adda.l #2,a5 recherche aux addr paires.
cmpa.l a5,a4 fin IFF ?
bge 0$
bsr no_BODY
bra 70$
10$ adda.l #8,a5
move.l a5,_BODY
movea.l a5,a4 fin des chunks en a4
movea.l IFFFile,a5
adda.l #12,a5 apres 'FORM XXXX ILBM'.
20$ cmpi.l #'BMHD',(a5) cherchage du BMHD
beq 30$
adda.l #2,a5
cmpa.l a5,a4
bge 20$
bsr no_BMHD
bra 70$
30$ adda.l #8,a5
move.l a5,_BMHD
move.w bmhd_Width(a5),PicWidth
move.w bmhd_Height(a5),PicHeight
move.b bmhd_nPlanes(a5),PicDepth
move.b bmhd_Compression(a5),Compress
move.w bmhd_Width(a5),d6
addi.w #15,d6
lsr.w #4,d6 (w+15)/16=nbre de mots/ligne
move.w d6,WordsPerLine
movea.l IFFFile,a5
adda.l #12,a5 apres 'FORM XXXX ILBM'.
40$ cmpi.l #'CMAP',(a5) cherchage du CMAP
beq 50$
adda.l #2,a5
cmpa.l a5,a4
bge 40$
bset #MNOCMAPB,d7
bra 55$
50$ adda.l #4,a5 mot long juste après 'CMAP'
move.l a5,_CMAP pour nbre de couleurs
55$ movea.l IFFFile,a5
adda.l #12,a5 apres 'FORM XXXX ILBM'.
60$ cmpi.l #'DEST',(a5) cherchage du DEST
beq 65$
adda.l #2,a5
cmpa.l a5,a4
bge 60$
bra 70$
65$ adda.l #8,a5
move.l a5,_DEST
70$ move.l (sp)+,a4
rts
getplanepick: *** definit le planepick d'une picture
move.w d4,-(sp)
tst.l _DEST
beq 10$
movea.l _DEST,a1
move.w dest_planePick(a1),d2
bra 79$
10$ movea.l _BODY,a1
clr.w d0
move.b PicDepth,d0
subq.w #1,d0
clr.w d5
15$ bset d0,d5 d5 contiendra le planepick
dbra d0,15$
tst.b Compress
beq 71$
bset #MYETDECRUNCHEDB,d7
bsr byterun
71$ movea.l a1,a5 addr debut en a5 (body ou pseudrast)
clr.l d0
clr.l d4 d4=cpteur de bitplanes
clr.w d2 d2=cpteur de mots par ligne IFF
clr.w d1 d1=cpteur de lignes
move.b PicDepth,d4
subq.b #1,d4
72$ move.w PicHeight,d1
subq.w #1,d1
74$ move.w WordsPerLine,d2
subq.w #1,d2
76$ lsl.w #1,d2
tst.w (a1,d2)
bne 78$
lsr.w #1,d2
dbra d2,76$ cpteur de mots par ligne
clr.w d0
move.b PicDepth,d0
mulu WordsPerLine,d0
lsl.w #1,d0
adda.w d0,a1 on "saute" une ligne
dbra d1,74$ cpteur de lignes
neg.w d4 si il n'y a que des zeros
add.b PicDepth,d4 on clear le bit correspondant
subq.b #1,d4
bclr d4,d5 a ce plan dans d5
addq.b #1,d4
sub.b PicDepth,d4
neg.w d4
78$ clr.w d0
movea.l a5,a1 restore addr debut (body ou dest)
move.b PicDepth,d0
sub.b d4,d0
mulu WordsPerLine,d0
lsl.w #1,d0
adda.l d0,a1 on "saute" un bitplane
dbra d4,72$ cpteur de bitplanes
move.b d5,PlanePick
79$ move.w (sp)+,d4
rts
pickonoff: *decode planePick & PlaneOnOff
* attend la valeur en d2
move.w d2,d0
lsr.w #4,d0 XY -> 0X
cmpi.w #$A,d0
blt 76$
addq.w #$7,d0
76$ addi.w #$30,d0
move.b d0,(a4)+
move.w d2,d0
andi.w #$000F,d0 XY -> 0Y
cmpi.w #$A,d0
blt 77$
addq.w #$7,d0
77$ addi.w #$30,d0
move.b d0,(a4)+
rts
byterun: * decode l'iff crunchee dans le pseudoraster
move.w d5,-(sp)
.crunch clr.l d0
move.b PicDepth,d0
mulu WordsPerLine,d0
lsl.w #1,d0
mulu PicHeight,d0 pseudo raster dest pour decrunch
move.l d0,PseudoRasterLength
move.l #MEMF_PUBLIC,d1
CALLEXEC AllocMem
move.l d0,PseudoRaster
movea.l d0,a2 pseudoraster en a2
movea.l a2,a3
adda.l PseudoRasterLength,a3 fin du pseudoraster en a3
movea.l _BODY,a1
.decr clr.w d6
clr.w d5
move.b (a1)+,d6
bge .pos
.neg cmpi.b #$80,d6 d6=-128 ?
beq .decr
ext.w d6
neg.w d6
move.b (a1)+,d5 d6<0 : on prend son oppose,
15$ move.b d5,(a2)+ on copie n+1 fois l'octet
dbra d6,15$ suivant dans la dest.
cmpa.l a2,a3 fin du pseudoraster ?
bgt .decr
bra 16$
.pos move.b (a1)+,(a2)+
dbra d6,.pos
cmpa.l a2,a3 fin du pseudoraster ?
bgt .decr
16$ movea.l PseudoRaster,a1
move.w (sp)+,d5
rts
decodeiff:
movea.l IFFFile,a5
cmpi.l #'FORM',(a5)+ verifier si IFF
; bne IFFerr
move.l (a5)+,d0
add.l a5,d0
move.l d0,FormEnd sauver la taille du chunk form
cmpi.l #'ILBM',(a5)+ verifie si ILBM
; bne IFFerr
do move.l (a5)+,d7 on va etudier le FORM mot a mot
move.l (a5)+,d6
cBMHD cmpi.l #'BMHD',d7
bne cCMAP
clr.l d0
move.w bmhd_Width(a5),d0
addi.w #15,d0
divu #16,d0
andi.l #$0000FFFF,d0
mulu #16,d0
move.w d0,msc_W initialise la struct
move.w bmhd_Height(a5),msc_H NewScreen
move.b bmhd_nPlanes(a5),msc_D+1
tst.b bmhd_Compression(a5) tst le bit de compression
sne Compress si =1, poser le flag compress
bra loop et on va decompresser
cCMAP cmpi.l #'CMAP',d7
bne cCAMG
move.w d6,d7 longueur du chunk en d7
ext.l d7 chaque coul ayant ses param RGB
divu #3,d7 on div par 3 pr avoir le nb de coul
cmpi.w #32,d7
ble coulok
moveq #32,d7
coulok move.w d7,ColorCount
lea Palette,a2
moveq #0,d5
subq #1,d7
coloop move.b (a5)+,d5 recopie la palette du fichier dans
lsl.w #4,d5 notre palette
or.b (a5)+,d5
lsl.w #4,d5
or.b (a5)+,d5
lsr.w #4,d5
move.w d5,(a2)+
dbra d7,coloop
moveq #0,d6 annule d6
bra loop
cCAMG cmpi.l #'CAMG',d7
bne cBODY
move.l (a5),d0
andi.l #CAMGMASK,d0
move.w d0,msc_VM ViewModes
bra loop
cBODY cmpi.l #'BODY',d7
bne loop
lea MiceScreenStructure,a0
CALLINT OpenScreen
tst.l d0
bne 1$
bsr no_Screen
rts
1$ movea.l d0,a4 screenhandle en a4
move.l d0,a0
lea sc_ViewPort(a0),a0
lea Palette,a1
move.w ColorCount,d0
ext.l d0
CALLGRAF LoadRGB4 chargement palette
move.w msc_W,d5 largeur ecran en d5
lsr.w #3,d5 /8 pour avoir en octet
moveq #0,d0 d0 compteur de lignes
lignes move.l a4,a3
lea sc_BitMap+bm_Planes(a3),a3 adr bitplanes en a3
move.w msc_D,d1
subq.w #1,d1 depth-1 en d1
planes move.l (a3)+,a0 plan de bit en a0
move.w d0,d2 d0 compteur de lignes
mulu d5,d2 octet/ligne * n°ligne
lea (a0,d2.l),a0 adr de la ligne en a0
moveq #0,d2
tst.b Compress
beq normal
comp moveq #0,d3
move.b (a5)+,d3 octet suivant en d3
bmi crunch si<0, compression
ext.w d3 extension du signe +
add.w d3,d2
addq.w #1,d2 rang de l'octet sur la ligne
compl move.b (a5)+,(a0)+ on copie n+1 octet
dbra d3,compl
bra nextbyte
crunch cmpi.b #$80,d3 n=-128 ?
beq nextbyte
neg.b d3 on met d3 positif
ext.w d3 etend son signe +
add.w d3,d2
addq.w #1,d2 rang sur la ligne
move.b (a5)+,d4 on met l'octet concerne en d4
crunchl move.b d4,(a0)+ et on le copie 'd3' fois
dbra d3,crunchl
nextbyte
cmp.w d5,d2 est on a la fin de la ligne
blt comp (longueur en d5)
bra nextl
normal move.w d5,d4 si non compresse, longueur ligne
subq.w #1,d4 en d4
nloop move.b (a5)+,(a0)+ et copier les octets
dbra d4,nloop
nextl dbra d1,planes meme operation plan par plan
addq.w #1,d0 incremente le compteur de lignes
cmp.w msc_H,d0 compare avec largeur ecran
blt lignes
moveq #0,d6
loop adda.l d6,a5 ajoute la longeur du chunk
move.l a5,d6 au "iffpc"
andi.b #1,d6
beq pair
addq.l #1,a5 rendre pair si besoin
pair cmpa.l FormEnd,a5 fin de "FORM" ?
blt do
rts
endiff: * attend 1 click, libere IFFFile, ferme l'ecran
1$ CALLGRAF WaitTOF
btst #6,$BFE001
bne 1$
movea.l a4,a0
CALLINT CloseScreen
endiff1
movea.l IFFFile,a1
move.l IFFSize,d0
CALLEXEC FreeMem
rts
free_PseudoRaster:
tst.l PseudoRaster
beq 1$
movea.l PseudoRaster,a1
move.l PseudoRasterLength,d0
CALLEXEC FreeMem
clr.l PseudoRaster
1$ rts
dcb:
lea dcbPattern,a3 "dc.b..."
move.w #dcbPatternLength-1,d5
0$ move.b (a3)+,(a4)+
dbra d5,0$
rts
dcw:
lea dcwPattern,a3 "dc.w..."
move.w #dcwPatternLength-1,d5
0$ move.b (a3)+,(a4)+
dbra d5,0$
rts
write_close_free:
move.l SourceCodeHandle,d1
move.l SourceFile,d2
move.l ReqMem,d3
CALLDOS Write
move.l SourceCodeHandle,d1
CALLDOS Close
move.l ReqMem,d0
movea.l SourceFile,a1
CALLEXEC FreeMem
rts
dcl:
lea dclPattern,a3 "dc.l..."
move.w #dclPatternLength-1,d5
0$ move.b (a3)+,(a4)+
dbra d5,0$
rts
alloc_ReqMem:
move.l ReqMem,d0
move.l #MEMF_PUBLIC|MEMF_CLEAR,d1
CALLEXEC AllocMem
move.l d0,SourceFile
rts
init_loop_1f:
movea.l IFFFiles,a5
move.l a5,IFFFilePtr
move.l (a5),IFFFile
movea.l IFFSizes,a5
move.l a5,IFFSizePtr
move.l (a5),IFFSize
movea.l ListOfFNLength,a5
move.l a5,FNLengthPtr
move.w (a5),FileNameLength
rts
inc_loop_1f:
movea.l IFFFilePtr,a5
addq.l #4,a5
move.l a5,IFFFilePtr
move.l (a5),IFFFile
movea.l IFFSizePtr,a5
addq.l #4,a5
move.l a5,IFFSizePtr
move.l (a5),IFFSize
movea.l FNLengthPtr,a5
addq.l #2,a5
move.l a5,FNLengthPtr
move.w (a5),FileNameLength
rts
save_code:
bsr free_PseudoRaster
move.l #SourceCodeName,d1
move.l #MODE_NEWFILE,d2
CALLDOS Open
move.l d0,SourceCodeHandle
bsr write_close_free
rts
seek_code:
bsr free_PseudoRaster
move.l #SourceCodeName,d1
move.l #MODE_OLDFILE,d2
CALLDOS Open
move.l d0,SourceCodeHandle
move.l d0,d1
clr.l d2
moveq #OFFSET_END,d3
CALLDOS Seek
bsr write_close_free
rts
no_open_file:
25$ lea File,a1
lea Error_24,a0
30$ cmpi.b #0,(a1)
beq 35$
move.b (a1)+,(a0)+
bra 30$
35$ move.b #39,(a0)+ #39 = chr '
move.b #0,(a0)
move.l #Error_20,mtr_Text
move.l #ok,mtr_MiddleText
lea MiceTRStructure,a0
CALLREQ TextRequest
bset #MNOLOADB,d7
clr.l mtr_MiddleText
rts
no_IFF:
25$ lea File,a1
lea Error_34,a0
30$ cmpi.b #0,(a1)
beq 35$
move.b (a1)+,(a0)+
bra 30$
35$ move.b #39,(a0)+ #39 = chr '
lea Error_37,a1
move.w #Error_37_Length-1,d5
40$ move.b (a1)+,(a0)+
dbra d5,40$
move.b #0,(a0)
move.l #Error_30,mtr_Text
move.l #ok,mtr_MiddleText
lea MiceTRStructure,a0
CALLREQ TextRequest
bset #MNOIFFB,d7
clr.l mtr_MiddleText
rts
no_ILBM:
25$ lea File,a1
lea Error_44,a0
30$ cmpi.b #0,(a1)
beq 35$
move.b (a1)+,(a0)+
bra 30$
35$ move.b #39,(a0)+ #39 = chr '
lea Error_47,a1
move.w #Error_47_Length-1,d5
40$ move.b (a1)+,(a0)+
dbra d5,40$
move.b #0,(a0)
move.l #Error_40,mtr_Text
move.l #ok,mtr_MiddleText
lea MiceTRStructure,a0
CALLREQ TextRequest
bset #MNOILBMB,d7
clr.l mtr_MiddleText
rts
no_BODY:
25$ lea File,a1
lea Error_54,a0
30$ cmpi.b #0,(a1)
beq 35$
move.b (a1)+,(a0)+
bra 30$
35$ move.b #39,(a0)+ #39 = chr '
move.b #0,(a0)
move.l #Error_50,mtr_Text
move.l #ok,mtr_MiddleText
lea MiceTRStructure,a0
CALLREQ TextRequest
bset #MNOBODYB,d7
clr.l mtr_MiddleText
rts
no_BMHD:
25$ lea File,a1
lea Error_64,a0
30$ cmpi.b #0,(a1)
beq 35$
move.b (a1)+,(a0)+
bra 30$
35$ move.b #39,(a0)+ #39 = chr '
move.b #0,(a0)
move.l #Error_60,mtr_Text
move.l #ok,mtr_MiddleText
lea MiceTRStructure,a0
CALLREQ TextRequest
bset #MNOBMHDB,d7
clr.l mtr_MiddleText
rts
no_CMAP:
25$ lea File,a1
lea Error_74,a0
30$ cmpi.b #0,(a1)
beq 35$
move.b (a1)+,(a0)+
bra 30$
35$ move.b #39,(a0)+ #39 = chr '
move.b #0,(a0)
move.l #Error_70,mtr_Text
move.l #ok,mtr_MiddleText
lea MiceTRStructure,a0
CALLREQ TextRequest
clr.l mtr_MiddleText
rts
no_Screen:
move.l #Error_80,mtr_Text
move.l #ok,mtr_MiddleText
lea MiceTRStructure,a0
CALLREQ TextRequest
bset #MNOSCREENB,d7
clr.l mtr_MiddleText
rts